package vivace.view.openDialogue;

import java.io.File;
import javax.swing.filechooser.*;


/**
 * A class to filter the files in the open dialogue to only chosen ones
 */
public class ImageFilter extends FileFilter {
	
	/**
	 * Accept all directories and the chosen extensions
	 * 
	 * @param	File	file	The files in open dialogue
	 * @return				returns true or false depending on wheter the file is of the chosen extension
	 */
    public boolean accept(File file) {
    	
    	//If the file is a directory, then show it
        if (file.isDirectory()) {
            return true;
        } 

        //Load the extensions to be filtered
        String extension = Utils.getExtension(file);
        
      //If there is extensions to filter, find out wich type
        if (extension != null) {
        	
            if (extension.equals(Utils.mid) || extension.equals("midi")){ //if more extensions use: || extension.equals(Utils.mid))
                    return true;
            
            //Else then filter the file     
            } else {
                return false;
            }
        }
        return false;
    }

    //The description of this filter
    public String getDescription() {
        return "Midi File (.mid)";
    }
}
